package com.zsrt.scott.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.zsrt.scott.service.impl.StudentService;
import com.zsrt.scott.service.impl.StudentServiceWS;

public class CxfServlet extends HttpServlet {
	
	
	private static final long serialVersionUID = 1L;
	
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
		
		System.out.println("进入com.zsrt.scott.servlet.CxfServlet...");
		
		//1 调用远程ws服务  获取数据  然后返回json格式
		StudentServiceWS ws = new StudentServiceWS();
		
		StudentService service = ws.getStudentServicePort();
		
		Gson json = new Gson();
		
		String data = json.toJson(service.findAll());
		
		response.getWriter().write(data);
	}


}
